﻿@model Dyd.BaseService.ServiceCenter.Web.Models.ServiceViewModel
@using Dyd.BaseService.ServiceCenter.Web.Core
@{
    ViewBag.Title = "添加服务";
    Layout = "~/Views/Shared/_LayoutPage.cshtml";
    var list = XXF.ProjectTool.EnumHelper<XXF.BaseService.ServiceCenter.SystemRuntime.EnumServiceType>.GetAllEnumsOfList2().ToList();
    list = list.Where(s => s.Text != XXF.BaseService.ServiceCenter.SystemRuntime.EnumServiceType.None.ToString()).ToList();
    list.FirstOrDefault(s => s.Text == XXF.BaseService.ServiceCenter.SystemRuntime.EnumServiceType.Thrift.ToString()).Selected = true;
}

<div class="main_content">
    <div class="top">
        <h3 class="fl">@ViewBag.Title</h3>
        <a class="fr back" href="javascript:history.go(-1)">返回</a>
    </div>
    <div class="main mt10 pt10">
        <div class="fl edit2">
            @using (Html.BeginForm())
            {
                @Html.AntiForgeryToken()
                @Html.ValidationSummary(true)
                <ul class="mydetail">
                    <li class="fm_item">
                        @Html.LabelFor(model => model.tb_service.servicename)：
                        @Html.TextBoxFor(model => model.tb_service.servicename, new { @maxlength = 200 })
                        @Html.ValidationMessageFor(model => model.tb_service.servicename)
                    </li>
                    <li class="fm_item">
                        @Html.LabelFor(model => model.tb_service.servicenamespace)：
                        @Html.TextBoxFor(model => model.tb_service.servicenamespace, new { @maxlength = 255 })
                        <span>@Config.ServiceNameSpanceTip</span>
                        @Html.ValidationMessageFor(model => model.tb_service.servicenamespace)
                    </li>
                    <li class="fm_item">
                        @Html.LabelFor(model => model.tb_service.servicetype)：
                        @Html.DropDownListFor(model => model.tb_service.servicetype, list)
                        @Html.ValidationMessageFor(model => model.tb_service.servicetype)
                    </li>

                    @*<li class="fm_item">
                            @Html.LabelFor(model => model.tb_service.istest)：
                            @Html.EditorFor(model => model.tb_service.istest)
                            @Html.ValidationMessageFor(model => model.tb_service.istest)
                        </li>
                        <li class="fm_item">
                            @Html.LabelFor(model => model.tb_service.isautoboostpercent)：
                            @Html.EditorFor(model => model.tb_service.isautoboostpercent)
                            @Html.ValidationMessageFor(model => model.tb_service.isautoboostpercent)
                        </li>*@
                    @*<li class="fm_item">
                            @Html.LabelFor(model => model.tb_service.protocolversion)：
                            @Html.TextBoxFor(model => model.tb_service.protocolversion, new { @maxlength = 8 })
                            @Html.ValidationMessageFor(model => model.tb_service.protocolversion)
                        </li>*@
                    <li class="fm_item">
                        @Html.LabelFor(model => model.tb_service.remark)：
                        @Html.TextAreaFor(model => model.tb_service.remark, new { @rows = 12 })
                        @Html.ValidationMessageFor(model => model.tb_service.remark)
                    </li>

                    <li class="fm_item" style="margin-top: 10px;">
                        <p class="box">
                            <input id="btnSave" type="button" class="btn ml200 " value="保存" />
                        </p>
                    </li>
                </ul>
            }
        </div>
    </div>
</div>
@section Scripts{
    <script src="~/Scripts/jquery.validate.min.js"></script>
    <script src="~/Scripts/jquery.validate.unobtrusive.min.js"></script>
    <script>
        $(function () {
            $("#btnSave").click(function () {
                if ($("form").valid()) {
                    var data = $("form").serialize();
                    $.ajax({
                        url: "/Service/ServiceCreate",
                        type: "post",
                        data: data,
                        dataType: "json",
                        success: function (data) {
                            if (data.Flag) {
                                alert(data.Message);
                                window.location = "/Service/ServiceIndex";
                            } else {
                                alert(data.Message);
                            }
                        }
                    });
                }
            });
        });
    </script>
}